<?php

  require_once "JooS/Server/Resource/DataNode.php";

  abstract class JooS_Server_Resource_DataContent extends JooS_Server_Resource_DataNode implements ArrayAccess {
    private $_attributes = null;

    public function __construct($name) {
      parent::__construct($name);

      require_once "JooS/Server/Resource/DataAttr/List.php";
      $this->_attributes = new JooS_Server_Resource_DataAttr_List();
    }

    public function __get($name) {
      switch ($name) {
        case "attributes":
          return $this->_attributes;
        case "nodeValue":
          $nodeValue = array( $this->getNodeName() );
          if (count($this->_attributes)) {
            $attributes = array();
            foreach ($this->_attributes as $k => $v)
              $attributes[$k] = $v;
            $nodeValue[] = (object)$attributes;
          }
          return $nodeValue;
        default:
          return parent::__get($name);
      }
    }

    public function offsetExists($offset) {
      return $this->_attributes->offsetExists($offset);
    }

    public function offsetGet($offset) {
      return $this->_attributes->offsetGet($offset);
    }

    public function offsetSet($offset, $value) {
      $this->_attributes->offsetSet($offset, $value);
    }

    public function offsetUnset($offset) {
      $this->_attributes->offsetUnset($offset);
    }

    protected function getAttributes() {
      return $this->_attributes;
    }
  }

?>